<%@ page import="zhangcy.day0109.carlottery.dao.UserDao" %>
<%@ page import="zhangcy.day0109.carlottery.dao.impl.UserDaoImpl" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="zhangcy.day0109.carlottery.po.User" %>
<%@ page import="zhangcy.day0109.carlottery.constants.UserStatus" %><%--
  Created by IntelliJ IDEA.
  User: 小香菜
  Date: 2023/1/9
  Time: 11:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8" />
    <title>燃油汽车指标摇号系统</title>
    <link rel="stylesheet" href="../../../css/zhangcy/day0109/lottery-system.css" type="text/css">
<%--    <script type="text/javascript" src="../../../js/zhangcy/day0109/jquery-3.6.3.js"></script>--%>
<%--    <script type="text/javascript" src="../../../js/zhangcy/day0109/add_user.js"></script>--%>
    <%
        /* jsp组成部分：jsp小脚本  内置对象(9个内置对象)  jsp指令 */
        /* 在jsp页面中获取后端Java程序，进行数据交互 */
//        1、使用多态体现，实例化UserDao userDao数据访问层
        UserDao userDao = new UserDaoImpl();
//        2、创建map集合对象，用来存储查询李彪的搜索条件参数
        Map<String, Object> map = new HashMap<>();
        //        2.2、获取indexController.jsp中存储在request作用域中的searchName
        String searchName = request.getAttribute("searchName") == null ? "" :
               String.valueOf(request.getAttribute("searchName"));
        if (!"".equals(searchName)) {
            map.put("markNo", searchName);
        }
//        3、调用查询数据列表方法
        List<User> userList = userDao.queryUserBy(map);
    %>
</head>
<body>
<div id="container">
    <header>
        <h1>燃油汽车指标摇号系统</h1>
    </header>
    <div id="main_body">
        <div id="aside">
            <h2>功能列表展示</h2>
            <a href="#">参与摇号用户</a>
            <a href="lottery.jsp">摇号</a>
        </div>
        <div id="main_center">
            <!-- 列表展示 -->
            <form action="indexController.jsp" method="post">
                <div id="search">
                    <a href="add-lottery-user.jsp"><input type="button" value="添加"></a>
                    <!-- 搜索表单 -->
                    <form class="example" method="post" action="indexController.jsp">
                        <input type="text" placeholder="中签编号.." name="search">
                        <button class="btnSeach">搜索</button>
                    </form>
                </div>
                <!-- <table border="1px"> -->
                <table>
                    <thead>
                        <tr>
                            <th>姓名</th>
                            <th>中签编号</th>
                            <th>持照状态</th>
                            <th>手机号码</th>
                            <th>开户日期</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                    <%
                        for (int i = 0; i < userList.size(); i++) {
                    %>
                        <tr>
                            <td><%=userList.get(i).getUserName()%></td>
                            <td><%=userList.get(i).getMarkNo()%></td>
                            <td><%=UserStatus.getUserStatusByCode(userList.get(i).getStatus()).getValue()%></td>
                            <td><%=userList.get(i).getPhone()%></td>
                            <td><%=userList.get(i).getOpenDate()%></td>
                            <td>
                                <a href="">详情</a>&nbsp;&nbsp;&nbsp;
                                <a href="javascript:void(0);" class="del">删除</a>
                            </td>
                        </tr>
                    <%
                        }
                    %>
                    </tbody>
                </table>
            </form>
        </div>
    </div>
</div>
</body>
</html>
